class User {
  constructor(role, pages) {
    this.role = role;
    this.pages = pages;
  }

  static UserFactory(role) {
    switch (role) {
      case "superadmin":
        return new User(role, ["home", "user-manage", "news-manage"]);
        break;
      case "admin":
        return new User(role, ["home", "news-manage"]);
        break;
      case "user":
        return new User(role, ["home"]);
        break;
      default:
        throw "参数错误！";
        break;
    }
  }
}

const sadmin = User.UserFactory("superadmin");
const admin = User.UserFactory("admin");
const user = User.UserFactory("user");
console.log(sadmin);
console.log(admin);
console.log(user);

const err = User.UserFactory("error");
